import { contextBridge, ipcRenderer } from 'electron'
import type { CheckForUpdateCallback } from './types'
import type { Student, Shortcut } from './db'

contextBridge.exposeInMainWorld('electron', {
  ipcRenderer,
  onCheckForUpdate: (callback: CheckForUpdateCallback) => ipcRenderer.on('check-for-updates', (_event, value) => callback(value)),
  insertStudent: (student: Omit<Student, 'id'>) => ipcRenderer.invoke('insert-student', student),
  getAllStudents: () => ipcRenderer.invoke('get-all-students'),

  getShortcuts: () => ipcRenderer.invoke('get-shortcuts'),
  saveShortcuts: (shortcuts: Shortcut[]) => ipcRenderer.invoke('save-shortcuts', shortcuts),
})

contextBridge.exposeInMainWorld('electronAPI', {

})
